sum of digit of number c#

58

sum of digit of number c# -

sum = 0;
while (n != 0) {
    sum += n % 10;
    n /= 10;
}

sum of digit of number c# -

int result = 17463.ToString().Sum(c => Convert.ToInt32(c));

Comments

Submit
0 Comments